# Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
# Project developers.  See the top-level LICENSE file for dates and other
# details.  No copyright assignment is required to contribute to VisIt.

#*****************************************************************************
# Modifications:
#   Kathleen Biagas, Thu Sep 27 11:35:34 PDT 2018
#   Change PYTHON_LIBRARIES to PYTHON_LIBRARY for consistency throughout visit.
#
#*****************************************************************************

set(pyqtgui_include_paths ${CMAKE_CURRENT_SOURCE_DIR}
                    ${VISIT_PYTHON_DIR}/include
                    ${VISIT_SIP_DIR}/include
                    ${VISIT_SIP_DIR}/include/python${PYTHON_VERSION}
                    ${VISIT_SOURCE_DIR}/viewer/core 
                    ${VISIT_SOURCE_DIR}/viewer/main 
                    ${VISIT_SOURCE_DIR}/viewer/main/ui
                    ${VISIT_SOURCE_DIR}/viewer/proxy
                    ${VISIT_SOURCE_DIR}/viewer/subjectproxy
                    ${VISIT_SOURCE_DIR}/viewer/rpc
                    ${VISIT_SOURCE_DIR}/vtkqt
                    ${VISIT_SOURCE_DIR}/common/utility
                    ${VISIT_SOURCE_DIR}/common/state
                    ${VISIT_SOURCE_DIR}/common/misc
                    ${VISIT_SOURCE_DIR}/common/comm
                    ${VISIT_SOURCE_DIR}/common/plugin
                    ${VISIT_SOURCE_DIR}/common/Exceptions/Pipeline
                    ${VISIT_SOURCE_DIR}/avt/DBAtts/MetaData/
                    ${VISIT_SOURCE_DIR}/avt/DBAtts/SIL
                    ${VTK_INSTALL_PREFIX}/include/vtk-5.0
                    ${VISIT_SOURCE_DIR}/avt/Math
                    ${VISIT_SOURCE_DIR}/avt/VisWindow/VisWindow
                    ${VISIT_SOURCE_DIR}/avt/Plotter/
                    ${VISIT_SOURCE_DIR}/avt/Plotter/vtk
                    ${VISIT_SOURCE_DIR}/visit_vtk/full
                    ${VISIT_SOURCE_DIR}/gui
                    ${VISIT_SOURCE_DIR}/visitpy/pyui/common
                    ${VISIT_SOURCE_DIR}/winutil
                    ${CMAKE_BINARY_DIR}/include
)

set(pyqtgui_link_libs
                      #gui
                      guiwrapper
                      #viewerproxy
                      #viewersubjectproxy
                      #vtkqt
                      #${QT_QTCORE_LIBRARY}
                      ${PYTHON_LIBRARY}
                      )

SET(SIP_LIBRARY "pyqt_gui")
SET(SIP_EXECUTABLE "${VISIT_SIP_DIR}/bin/sip")
SET(SIP_FILE "${CMAKE_CURRENT_SOURCE_DIR}/pyqtgui.sip")
MESSAGE(STATUS "Configuring ${SIP_LIBRARY}")
SET(pyqtgui_sources 
                 ${CMAKE_CURRENT_SOURCE_DIR}/pyqtgui.C
                 ${CMAKE_CURRENT_BINARY_DIR}/sippyqt_guiPyQtGUI.cpp
                 ${CMAKE_CURRENT_BINARY_DIR}/sippyqt_guicmodule.cpp)

SET(PYQT_QT_VERSION "Qt_${QT_VERSION_MAJOR}_${QT_VERSION_MINOR}_0") #${QT_VERSION_PATCH}

if(WIN32)
  SET(PYQT_QT_DEVICE "WS_WIN")
elseif(APPLE)
#for some reason sip on mac does not like patch..
SET(PYQT_QT_VERSION "Qt_${QT_VERSION_MAJOR}_${QT_VERSION_MINOR}_0")
SET(PYQT_QT_DEVICE "WS_MACX")
else()
  SET(PYQT_QT_DEVICE "WS_X11")
endif()

MESSAGE(STATUS ${SIP_EXECUTABLE} "-t" ${PYQT_QT_VERSION} "-t" ${PYQT_QT_DEVICE} "-I" ${VISIT_SIP_DIR}/share/sip/PyQt4 "-I" ${VISIT_SIP_DIR}/share "-c" ${CMAKE_CURRENT_BINARY_DIR} ${SIP_FILE})
EXECUTE_PROCESS(COMMAND ${SIP_EXECUTABLE} "-t" ${PYQT_QT_VERSION} "-t" ${PYQT_QT_DEVICE} "-I" ${VISIT_SIP_DIR}/share/sip/PyQt4 "-I" ${VISIT_SIP_DIR}/share "-c" ${CMAKE_CURRENT_BINARY_DIR} ${SIP_FILE})

ADD_DEFINITIONS("-fvisibility=default")
include_directories(${pyqtgui_include_paths})
ADD_LIBRARY(${SIP_LIBRARY} MODULE ${pyqtgui_sources})
SET_TARGET_PROPERTIES(${SIP_LIBRARY} PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(${SIP_LIBRARY} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/site-packages/visit)
TARGET_LINK_LIBRARIES(${SIP_LIBRARY} ${pyqtgui_link_libs})
VISIT_INSTALL_TARGETS_RELATIVE("site-packages/visit" ${SIP_LIBRARY})

